package com.sanen.flyer.main;

import com.sanen.flyer.tool.Console;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * @author wsse
 * @date 2018-09-29 17:27
 */
public class test {

    public static void main(String[] args) throws JavaLayerException, FileNotFoundException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("./music/energyfull.mp3"));
        Player player = new Player(bis);
        new Thread(() -> {
            try {
                player.play();
            } catch (JavaLayerException e) {
                e.printStackTrace();
            }
        }).start();
        new Thread(()->{

            while(true){
                try {
                    Console.log("position:",player.getPosition());
                    Thread.sleep(1000);
                    if (player.getPosition()==0){
                        player.play();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (JavaLayerException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }
}
